<?php
class AdsiteService{
	
	public  $dbutil;
    function __construct($dbutil){
	  	$this->dbutil =  $dbutil;
	} 
	 
 
	/**
	* 根据用户名获取用户信息
	* Enter description here ...
	* @param unknown_type $name
	*/
	function getAdminByID($id){
		return $this->dbutil->get_row("select * from ad_sites where site_id='".$id."'");
	}
 
	public function getStaticSites(){
		$sql = "select site_id,site_name from ad_sites group by site_name";
		return $this->dbutil->get_results($sql);
	}
	
	public function userPage($start , $page_size ){
		$limit ="";
		if($page_size){
			$limit =" limit $start,$page_size ";
		}
		$sql = "select * from ad_sites order by site_id $limit";
		return $this->dbutil->get_results($sql);
	
	 
	}
	public function countNum(){
		$sql = "select count(site_id) countnum from ad_sites";
    	$resutrnarry=	$this->dbutil->get_results($sql);
    	return $resutrnarry[0]->countnum;
	}
	
	public function addItem($data){
		return	$this->dbutil->insert("ad_sites", $data);
	}

	public function deleteItem($id){
		$sql = " delete from ad_sites where site_id= '".$id."'";
		return $this->dbutil->get_results($sql);
	}
	public function edit($data,$conditions){
		return $this->dbutil->update("ad_sites",$data,$conditions);
	}
 
	public function getIndexPage($limit){
		$sql = "SELECT * FROM ad_sites ORDER BY showindex LIMIT $limit";
		return $this->dbutil->get_results($sql);
	}
	
	
}